<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CronGo - 定时任务管理系统</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css" rel="stylesheet">
    <style>
        .task-group {
            cursor: pointer;
        }
        .task-status-1 {
            color: #28a745;
        }
        .task-status-2 {
            color: #dc3545;
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container">
            <a class="navbar-brand" href="#">CronGo</a>
        </div>
    </nav>

    <div class="container mt-4">
        <div class="row">
            <!-- 左侧任务组列表 -->
            <div class="col-md-3">
                <div class="card">
                    <div class="card-header d-flex justify-content-between align-items-center">
                        任务组
                        <button class="btn btn-sm btn-primary" onclick="showCreateTaskModal()">
                            <i class="bi bi-plus"></i> 新建任务
                        </button>
                    </div>
                    <div class="list-group list-group-flush" id="taskGroups">
                        <!-- 任务组将通过 JavaScript 动态加载 -->
                    </div>
                </div>
            </div>

            <!-- 右侧任务列表 -->
            <div class="col-md-9">
                <div class="card">
                    <div class="card-header">
                        任务列表 - <span id="currentGroup">全部</span>
                    </div>
                    <div class="card-body">
                        <table class="table">
                            <thead>
                                <tr>
                                    <th>任务名称</th>
                                    <th>Cron 表达式</th>
                                    <th>所属组</th>
                                    <th>状态</th>
                                    <th>最后执行时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody id="taskList">
                                <!-- 任务列表将通过 JavaScript 动态加载 -->
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 创建/编辑任务模态框 -->
    <div class="modal fade" id="taskModal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="taskModalTitle">新建任务</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <form id="taskForm">
                        <input type="hidden" id="taskId">
                        <div class="mb-3">
                            <label class="form-label">任务名称</label>
                            <input type="text" class="form-control" id="taskName" required>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">所属组</label>
                            <input type="text" class="form-control" id="groupName" required>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">Cron 表达式</label>
                            <input type="text" class="form-control" id="cronExpr" required>
                            <div class="form-text">示例：*/5 * * * * *（每5秒执行一次）</div>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">执行命令</label>
                            <textarea class="form-control" id="command" rows="3" required></textarea>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" onclick="saveTask()">保存</button>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script src="/static/js/main.js"></script>
</body>
</html> 